
package com.tool.btn;

import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import come.tool.Fighting.FightingMixDeal;
import come.tool.JDialog.TiShiUtil;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.List;

import come.tool.handle.HandleState;
import org.come.Frame.*;
import org.come.Jpanel.AlreadyRecordedJpanel;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.Jpanel.PalacePKJpanel;
import org.come.Jpanel.TestpackJapnel;
import org.come.baitan.BaiTanJframe;
import org.come.bean.LoginResult;
import org.come.bean.RoleShow;
import org.come.entity.Fly;
import org.come.model.InternalForm;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.summonequip.JframeCashRewardsMain;
import org.come.until.*;

import javax.swing.*;



public class GoodPanelBtn extends MoBanBtn {

    private int caozuo;

    public GoodPanelBtn(String iconpath, int type, String text) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG2);
        this.setText(text);
        this.setFont(UIUtils.TEXT_FONT82);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
    }

    public GoodPanelBtn(String iconpath, int type, String text, String sm, String jm) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG2);
        this.setText(text);
        this.setFont(UIUtils.TEXT_FONT82);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
    }

    //    物品栏上按键字体颜色
    public GoodPanelBtn(String iconpath, int type, String text, String sm) {
        super(iconpath, type, UIUtils.COLOR_BTNPUTONG2);//UIUtils.COLOR_WHITE1
        this.setText(text);
        if (sm != null) {
            this.setText(sm);
        }
        this.setFont(UIUtils.TEXT_HY88);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);

    }



    public void chooseyes() {
    }

    @Override
    public void chooseno() {
    }

    @Override
    public void nochoose(MouseEvent e) {
        if ("设".equals(this.getText()) || "设置密码".equals(this.getText())) {
            FormsManagement.showForm(689);
        } else if ("密".equals(this.getText()) || " ".equals(this.getText())) {
            if (RoleData.getRoleData().getLoginResult().getPassword() == null) {
                FormsManagement.showForm(32);

            }else {

                FormsManagement.showForm(21);
            }
        } else if ("改".equals(this.getText()) || "修改密码".equals(this.getText())) {
            FormsManagement.showForm(21);
        } else if (!"锁".equals(this.getText()) && !"解".equals(this.getText())) {
            if ("星录".equals(this.getText())) {
                FormsManagement.showForm(95);
            }
//            else if (this.getText().equals("星盘")) {
//                LoginResult login=RoleData.getRoleData().getLoginResult();
//                if(login.getTurnAround() <3){
//                    ZhuFrame.getZhuJpanel().addPrompt2("三转以上才能修炼星盘");
//                    return;
//                }
//                FormsManagement.showForm(122);
//            }

            else if ("摆摊".equals(this.getText())) {
                if (Util.isCanBuyOrno()) {
                    return;
                }
                // //在线摆摊
                // //判断是否有在可以摆摊的地图上(可以摆摊的地图ID:1207、1228、1236)
                RoleShow roleShow = ImageMixDeal.userimg.getRoleShow();
//            if (roleShow.getMapid() != 1207L) {
//                ZhuFrame.getZhuJpanel().addPrompt("只能在长安城摆摊");
//                return;
//            } // x 200 y195 x143 y 207

//            if (roleShow.getX() < 3000  || roleShow.getX() > 4000) {
//                ZhuFrame.getZhuJpanel().addPrompt("该区域不可以摆摊！");
//                return;
//            }
//            if (roleShow.getY() < 3560 || roleShow.getY() > 4140) {
//                ZhuFrame.getZhuJpanel().addPrompt("该区域不可以摆摊！");
//                return;
//            }
                if (roleShow.getMapid() != 1236) {
                    ZhuFrame.getZhuJpanel().addPrompt("只能在洛阳集市摆摊");
                    return;
                }
                if (roleShow.getX() < 5977 || roleShow.getX() > 8290) {
                    ZhuFrame.getZhuJpanel().addPrompt("该区域不可以摆摊！");
                    return;
                }
                if (roleShow.getY() < 3099 || roleShow.getY() > 4174) {
                    ZhuFrame.getZhuJpanel().addPrompt("该区域不可以摆摊！");
                    return;
                }
                if (roleShow.getTroop_id() == null && !FormsManagement.getframe(14).isVisible()
                        && FightingMixDeal.State == HandleState.USUAL) {
                  //  stall();
                } else {
                    ZhuFrame.getZhuJpanel().addPrompt2("当前状态不能摆摊！");
                }
                BaiTanJframe.getBaiTanJframe().getBaiTanJpanel().init();
                BoothBoxJframe.getBoothboxjframe().setLocation(20, 70);
                //  FormsManagement.showForm(15);
                // FormsManagement.showForm(16);
                FormsManagement.HideForm(0);
                FormsManagement.showForm(2260);
            } else if ("当前物品栏整理".equals(this.getText())) {
                TestpackJapnel.showIsTeamBtnS(false, 1);
                GoodsListFromServerUntil.arrange();
            }
//            else if (this.getText().equals("整理")) {
//                GoodsListFromServerUntil.arrange();
//            }
            else if ("全部物品栏整理".equals(this.getText())) {
                TestpackJapnel.showIsTeamBtnS(false, 1);
                GoodsListFromServerUntil.allArrange();
            } else if ("当前物品栏清理".equals(this.getText())) {
                TestpackJapnel.showIsTeamBtnS(false, 1);
                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.ClearAllGood, null, "#W此功能为#R一键清包#W，会将#Y当前打开的物品栏#W中的非加锁物品全部丢弃，你确定要这么操作吗? #R（注意，物品丢弃后无法找回！）");
            } else if ("勇者".equals(this.getText())) {
                /**判断是否解锁*/
                if (Util.isCanBuyOrno()) {
                    return;
                }
                JframeCashRewardsMain.getJframeCashRewardsMain().getJpanelCashRewardsMain().setGoodsType(3);
                FormsManagement.showForm(92);
            } else if ("一键回收".equals(this.getText())) {//一键回收
                OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.SellAllGood, null, "#W此功能为#R一键回收#W，会将#Y当前打开的物品栏#W中的非加锁且可回收物品全部回收，你确定要这么操作吗? #R（注意，物品回收后不可找回！）");
            } else if ("星盘".equals(this.getText())) {//星盘
                LoginResult login = RoleData.getRoleData().getLoginResult();
                if (login.getTurnAround() < 3) {
                    ZhuFrame.getZhuJpanel().addPrompt2("三转以上才能修炼星盘");
                    return;
                }
                FormsManagement.showForm(122);
            }
        } else if (Util.canBuyOrno) {
            Util.canBuyOrno = false;
            ImageMixDeal.userimg.Dialogue("背包已加锁！");
            FrameMessageChangeJpanel.addtext(6, "背包已加锁！", null, null);
            this.setText("解");
        } else if (RoleData.getRoleData().getLoginResult().getPassword() == null) {
            FormsManagement.showForm(689);
        } else {
            FormsManagement.showForm(33);
        }
    }

    /**
     * 摆摊按钮
     */
    public static void stall() {
        if (BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getStall().getId() == 0) {
            try {
                BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnTheshelves()
                        .setIcons(CutButtonImage.cuts("skin/8100226/newbutton/B20.png"));
                BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnTheshelves().setBtn(1);
                BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnshelves()
                        .setIcons(CutButtonImage.cuts("skin/8100226/newbutton/B20.png"));
                BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnshelves().setBtn(1);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnStall().setText("摆摊");
        } else {
            if (ImageMixDeal.userimg.getRoleShow().getBooth_id() != null) {
                try {
                    BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnTheshelves()
                            .setIcon(CutButtonImage.getImage("skin/8100226/newbutton/aj1h.png", -1, -1));
                    BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnTheshelves().setBtn(-1);
                    BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnshelves()
                            .setIcon(CutButtonImage.getImage("skin/8100226/newbutton/aj1h.png", -1, -1));
                    BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnshelves().setBtn(-1);
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                BoothBoxJframe.getBoothboxjframe().getBoothboxjpanel().getBtnStall().setText("收摊");
            }
        }
        TradeJframe.getTradejframe().getTradejpanel().getModelname().removeAllElements();
        if (UserMessUntil.getPetListTable() != null) {
            for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                TradeJframe.getTradejframe().getTradejpanel().getModelname()
                        .add(i, UserMessUntil.getPetListTable().get(i).getSummoningname());
            }
        }
        BoothBoxJframe.getBoothboxjframe().setLocation(20, 70);
        FormsManagement.showForm(15);
        FormsManagement.showForm(16);
        FormsManagement.HideForm(0);
    }


}


